﻿namespace MetaProperties.Framework
{
    using System;

    /// <summary>
    /// Extensions to the MetaPropertyies framework.
    /// </summary>
    public static class Extensions
    {
        /// <summary>
        /// Gets the requested MetaProperty.
        /// </summary>
        /// <typeparam name="T">The type of the property.</typeparam>
        /// <param name="host">The host of the property.</param>
        /// <param name="propertyName">Name of the property.</param>
        /// <returns>A MetaProperty if found; otherwise null.</returns>
        public static IMetaProperty<T> GetMetaProperty<T>(this IMetaPropertyHost host, string propertyName)
        {
            if (host == null)
            {
                throw new ArgumentNullException("host");
            }

            return (IMetaProperty<T>)host.GetMetaProperty(propertyName);
        }
    }
}
